package flex.ascript.ctrls
{
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.text.TextField;
	
	import mx.collections.ArrayCollection;
	import mx.controls.CheckBox;
	import mx.controls.DataGrid;
	import mx.controls.dataGridClasses.DataGridColumn;
	import mx.core.IFactory;

	public class CheckBoxHeaderRenderer extends CheckBox implements IFactory
	{
		//实现IFactory接口
		public var properties:Object;
		public function newInstance():*
		{
			var instance:Object = this;
			if (properties != null)
			{
				for (var p:String in properties)
				{
					instance[p] = properties[p];
				}
			}
			return instance;
		}
		
		public function CheckBoxHeaderRenderer()
		{
			super();
			this.toolTip = "全选";
		}
		
		// 控制CheckBox居中展现  
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void   
		{
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			var n:int = numChildren;
			for(var i:int = 0; i < n; i++)
			{
				var c:DisplayObject = getChildAt(i);
				if( !(c is TextField))
				{
					c.x = Math.round((unscaledWidth - c.width) / 2);
					c.y = Math.round((unscaledHeight - c.height) /2 );
				}
			}
		}
		
	}
}